<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/react.development.js"></script>
    <script src="lib/react-dom.development.js"></script>
    <script src="lib/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
</body>
<script type="text/babel">
    const root = ReactDOM.createRoot(document.querySelector("#root"));
    class App extends React.Component{
        state = {
            num:1,
            userName:"zhangsan"
        }
        // 1- 当挂载时执行一次
        // 2- 当this.setState时执行一次
        render(){
            console.log("render",this.state.num)
            return (
                <div>
                    <button onClick = {()=>{
                        // this.setState({num:1})
                        // this.state.num++;// 2
                        // 1
                        // this.setState({
                        //     num:this.state.num++
                        // })


                        // this.state.num++;
                        // this.setState({num:2})
                        // this.setState({
                        //     num:++this.state.num
                        // })


                        // this.setState({
                        //     num:100,
                        //     userName:"lisi"
                        // })

                        this.setState({
                            num:100
                        })

                        this.setState({
                            userName:"lisi"
                        })
                    }}>{this.state.num}</button>
                </div>
            )
        }
    }
    root.render((
        <App></App>
    ))
</script>
</html>